string.split = function(s, pattern)
    local start = 1
    local words = {}
    while true do
        local pos, to = string.find(s, pattern, start, true)
        if not pos then
            local tail = string.sub(s, start)
            if tail then
                table.insert(words, tail)
            end
            break
        end
        table.insert(words, string.sub(s, start, pos -1))
        start = to + 1
    end
    return words
end

string.trim = function(s)
  return s:match'^%s*(.*%S)' or ''
end
